//
//  UserHeaderButton.swift
//  BusinessIOS
//
//  Created by Rain on 2018/11/20.
//  Copyright © 2018 XingJian Li. All rights reserved.
//

import UIKit

class UserHeaderButton: UIButton {

    var NumLabel: UILabel!
    var nameLabel: UILabel!
    
    //MARK:- 重写init函数
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        self.NumLabel = UILabel();
        self.NumLabel.text  = "0"
        self.NumLabel.textAlignment = .center
        
        self.NumLabel.font = UIFont.systemFont(ofSize:15)//一般方法
        self.addSubview(self.NumLabel)
      
        
        
        self.nameLabel = UILabel();
      
        self.nameLabel.textAlignment = .center
        
        self.nameLabel.font = UIFont.systemFont(ofSize:12)//一般方法
        self.addSubview(self.nameLabel)
        
        
    }
    
    //swift中规定:重写控件的init(frame方法)或者init()方法.必须重写 init?(coder aDecoder: NSCoder)
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func layoutSubviews() {
        super.layoutSubviews()
        
        self.NumLabel.frame = CGRect(x: 0, y: 0, width: self.frame.size.width, height: 30)
        self.nameLabel.frame = CGRect(x: 0, y: 30, width: self.frame.size.width, height: 20)
        
    }
    

}
